package 设计模式.Singleton;
/**
 * 饿汉式，创建时就生成对象
 *
 * */
public class HungrySingleton {

    private static final HungrySingleton hsl = new HungrySingleton();

    private HungrySingleton() {
    }

    public static HungrySingleton getInstance() {
        return hsl;
    }

    public static void main(String[] args) {
        HungrySingleton instance = HungrySingleton.getInstance();
        HungrySingleton instance1 = HungrySingleton.getInstance();
        System.out.println(instance1==instance);
    }
}
